class Ball extends Sprite {
    constructor(dir, x, y) {
        super(dir, 'images/ball.png', x, y)
        this.speedX = 5
        this.speedY = 5
        this.fire = false
    }
    onfire() {
        this.fire = true
    }
    setSpeedX(x) {
        this.sppedX = x
    }
    setSpeedY(y) {
        this.sppedY = y
    }
    move() {
        if (this.x < 0 || this.x > 400 - this.w) {
            this.speedX = -this.speedX
        }
        if (this.y < 0 || this.y > 300 - this.h) {
            this.speedY = -this.speedY
        }
        this.x += this.speedX
        this.y += this.speedY
    }
    killBlock(block) {
        var k = this.block.lifes
        if (!k) {
            this.block.alive = false
        }
    }
    rebound() {
        this.speedY *= -1
    }
    collied(a) {
        var b = this
        if (aInb(a.x, b.x, b.x + b.w) || aInb(b.x, a.x, a.x + a.w)) {
            if (aInb(a.y, b.y, b.y + b.h) || aInb(b.y, a.y, a.y + a.h)) {
                return true
            }
        }
        return false
    }
    hasPoint(x, y) {
        var o = this
        var xIn = x >= o.x && x <= o.x + o.w
        var yIn = y >= o.y && y <= o.y + o.h
        return xIn && yIn
    }
}